package com.have.to.vm;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;

/**
 * @Description: java类作用描述
 * @Author: ye0yeg
 * @CreateDate: 2021/4/29 15:51
 * @UpdateUser: 更新者：
 * @UpdateDate: 2021/4/29 15:51
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class BaseLiveData<T> extends MutableLiveData<T> {
    public BaseLiveData() {
    }

    public void observe(@NonNull LifecycleOwner owner, final DataObserver<T> observer) {
        if (observer != null) {
            this.observe(owner, new Observer<T>() {
                public void onChanged(@Nullable T t) {
                    observer.onChanged(t);
                }
            });
        }
    }

    public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) {
        super.observe(owner, observer);
    }
}
